"""
This module contains the class for the character Roy. Modifications to
his object should be done here.
"""

import pygame, math
from pygame.locals import *
from qnd import *

class Roy:
	"""
	This is the main class for the character Roy. Its update method
	should be called every frame as well as its draw method.
	"""
	sprite = load_image('roy.png')
	def __init__(self, (x,y)):
		self.x,self.y = x,y
		self.speed = 8 #The maximum speed Roy runs at
		self.direction = 0 #The direction Roy is facing
		self.inventory = [] #Is a list of items Roy is holding
		self.weapon = None #The current weapon Roy has
	def update(self,input):
		"""Call this every frame"""
		self.direction = math.degrees(math.atan2(self.y-input.mousey,input.mousex-self.x)) #Make roy face towards the mouse. You can ignore the trigenometry if you want.
		#Move based on which keys are pressed
		if input.keys[K_w]:
			self.y -= self.speed
		if input.keys[K_s]:
			self.y += self.speed
		if input.keys[K_a]:
			self.x -= self.speed
		if input.keys[K_d]:
			self.x += self.speed
	def draw(self,screen,camera):
		"""Call this function to draw roy onto the screen"""
		draw_image(screen, self.sprite, (self.x,self.y), angle=self.direction, center=True,camera=camera) #Draw the roy sprite rotated in the direction he's facing
